<extend name="public@base5"/>
<block name="head">
    <style>
        .dev-menu-wrap {
            margin-bottom: 15px;
        }
    </style>
</block>
<block name="main">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link active" href="{:url('Dev/index')}">{:lang('ADMIN_DEV_INDEX')}</a>
            </li>
        </ul>
        <div class="row margin-top-20">
            <div class="col-md-3 dev-menu-wrap d-grid">
                <a href="javascript:parent.openapp('{:url('Menu/index')}','dev_menu_index','{:lang('ADMIN_MENU_INDEX')}')"
                   class="btn btn-primary btn-block">{:lang('ADMIN_MENU_INDEX')}</a>
            </div>
            <div class="col-md-3 dev-menu-wrap d-grid">
                <a href="{:url('user/AdminUserAction/sync')}" class="btn btn-success btn-block">{:lang('USER_ADMINUSERACTION_SYNC')}</a>
            </div>
            <div class="col-md-3 dev-menu-wrap d-grid">
                <a href="javascript:parent.openapp('{:url('admin/Hook/index')}','dev_hook_index','{:lang('ADMIN_HOOK_INDEX')}')"
                   class="btn btn-info btn-block">{:lang('ADMIN_HOOK_INDEX')}</a>
            </div>
            <div class="col-md-3 dev-menu-wrap d-grid">
                <a href="{:url('admin/Hook/sync')}"
                   class="btn btn-outline-light btn-block">{:lang('ADMIN_HOOK_SYNC')}</a>
            </div>

            <php>
                $sub_menus=\app\admin\service\DevService::devMenus();
                $default_menus = [
                'admin/Menu/index' => ['app' => 'admin', 'controller' => 'Menu', 'action' => 'index'],
                'user/AdminUserAction/sync' => ['app' => 'user', 'controller' => 'AdminUserAction', 'action' =>
                'sync'],
                'admin/Hook/index' => ['app' => 'admin', 'controller' => 'Hook', 'action' => 'index'],
                'admin/Hook/sync' => ['app' => 'admin', 'controller' => 'Hook', 'action' => 'sync'],
                ];
            </php>
            <foreach name="sub_menus" item="sub_menu">
                <php>
                    $url=$sub_menu['app'].'/'.$sub_menu['controller'].'/'.$sub_menu['action'];
                    if(isset($default_menus[$url])){continue;}
                </php>
                <div class="col-md-3 dev-menu-wrap d-grid">
                    <php>
                        if (strpos($sub_menu['app'], 'plugin/') === 0) {
                        $pluginName = str_replace('plugin/', '', $sub_menu['app']);
                        $url = cmf_plugin_url($pluginName . "://".$sub_menu['controller'].'/'.$sub_menu['action']);
                        }else{
                        $url=url($url);
                        }

                        $lang_key=strtoupper($sub_menu['app']).'_'.strtoupper($sub_menu['controller']).'_'.strtoupper($sub_menu['action']);
                        $menu_lang_name=lang($lang_key);
                        $menu_name=$menu_lang_name===$lang_key?$sub_menu['name']:$menu_lang_name;
                    </php>
                    <a href="javascript:parent.openapp('{$url}','{$sub_menu.id}admin','{$menu_name}')"
                       class="btn btn-outline-light btn-block">{$menu_name}</a>
                </div>
            </foreach>
        </div>

    </div>
</block>
